Destroys a background created by background_create, freeing its slot for a later background_create call.
background_destroy(bg)| Name | Type |
|---|---|
bg | background |
Nothing.
Destroys a background created by background_create, freeing its slot for a later background_create call. A no-op on nothing, or on a background already destroyed - never an error to destroy something already gone.
Unlike a ref<obj>, a background carries no generation check: destroying one does not itself turn your own variable back into nothing the way a stale instance reference is automatically caught by instance_exists. The variable just keeps its old value, now a stale pointer, until you assign it nothing yourself. Get in the habit of resetting the variable right after destroying it - reading a stale, un-reset background variable later is undefined, not merely a wasted no-op.
backdrop = background_create(0, 0, ts_doc_dungeon);
background_destroy(backdrop);
backdrop = nothing;Creates a background and destroys it again right away - the last line is the part worth remembering: setting backdrop back to nothing is what makes a later if (backdrop != nothing) check trustworthy, since background_destroy itself never does that for you.
A no-op on `nothing`, or on a background already destroyed - never an error to destroy something already gone, the same posture instance_destroy already establishes. Unlike a ref<obj>, a `background` carries no generation check: destroying one does NOT itself turn your own variable back into `nothing` - the variable keeps its old value, now a stale pointer, until you assign it `nothing` yourself. Set the variable to `nothing` right after destroying it (`backdrop = nothing;`) if you plan to check it again later - reading a stale, un-reset `background` variable is undefined, not merely a wasted no-op.